<?php
defined('_JEXEC') or die;

JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('exercise.stylesheet');
$canDo	= ExercisesHelper::getActions();
$user		= JFactory::getUser();
$userId		= $user->get('id');
?>
<script type="text/javascript">
	Joomla.submitbutton = function(task)
	{
		if (task == 'question.cancel' || document.formvalidator.isValid(document.id('question-form'))) {
			Joomla.submitform(task, document.getElementById('question-form'));
		}
	}
</script>

<form action="<?php echo JRoute::_('index.php?option=com_exercises&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="question-form" class="form-validate">

<div class="width-60 fltlft">
	<fieldset class="adminform">
		<legend><?php echo empty($this->item->id) ? JText::_('COM_EXERCISES_NEW_QUESTION') : JText::sprintf('COM_EXERCISES_EDIT_QUESTION', $this->item->id); ?></legend>
		<ul class="adminformlist">
				
                                <li><?php echo $this->form->getLabel('name'); ?>
				<?php echo $this->form->getInput('name'); ?></li>
                                <li><?php echo $this->form->getLabel('alias'); ?>
				<?php echo $this->form->getInput('alias'); ?></li>
				<li><?php echo $this->form->getLabel('exer_id'); ?>
				<?php $this->form->getInput('exer_id'); ?></li>                                
                                <li><?php echo $this->form->getLabel('question'); ?>
				<?php echo $this->form->getInput('question'); ?></li>
                                <li><?php echo $this->form->getLabel('correct_answers'); ?>
				<?php echo $this->form->getInput('correct_answers'); ?></li>
				<?php if ($canDo->get('core.edit.state')) : ?>
					<li><?php echo $this->form->getLabel('state'); ?>
					<?php echo $this->form->getInput('state'); ?></li>
				<?php endif; ?>

				<li><?php echo $this->form->getLabel('id'); ?>
				<?php echo $this->form->getInput('id'); ?></li>
		</ul>

	</fieldset>
</div>

<div class="width-40 fltrt">
	<?php echo JHtml::_('sliders.start', 'exercise-question-sliders-'.$this->item->id, array('useCookie'=>1)); ?>

	<?php echo JHtml::_('sliders.panel', JText::_('COM_EXERCISES_GROUP_LABEL_PUBLISHING_QUESTION_DETAILS'), 'publishing-details'); ?>
		<fieldset class="panelform">
		<ul class="adminformlist">
			<?php foreach($this->form->getFieldset('publish') as $field): ?>
				<li>
					<?php if (!$field->hidden): ?>
						<?php echo $field->label; ?>
					<?php endif; ?>
					<?php echo $field->input; ?>
				</li>
			<?php endforeach; ?>
			</ul>
		</fieldset>
        
                
                 <input type="hidden" name="createdby" value="<?php echo $userId;?>" />
	<input type="hidden" name="task" value="" />
	<?php echo JHtml::_('form.token'); ?>
</div>

<div class="clr"></div>
</form>
